home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_539 / rpn / source / cleanup.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  50 lines

  1. /*------------------------------------*
  2.  | File: CLEANUP.c - MLO 900131 V1.00 |
  3.  | These routines perform cleanup for |
  4.  | program termination.               |
  5.  *------------------------------------*/
  6.  
  7. #include "rpn.h"
  8. #include "proto.h"
  9.  
  10. extern struct Window *Wrpn;
  11. extern struct Window *Wreg;
  12.  
  13. static void cleanMess(struct Window *pW);
  14.  
  15. void cleanup(
  16.   int code                      /* Completion code */
  17. )
  18. {/*--------------------------------------*
  19.   | Frees all Intuition resources and    |
  20.   | exits with the given completion code |
  21.   *--------------------------------------*/
  22.  
  23.   if (Wreg != NULL) {
  24.     CloseWindow(Wreg);
  25.   }
  26.  
  27.   if (Wrpn != NULL) {
  28.     ClearMenuStrip(Wrpn);
  29.     cleanMess(Wrpn);
  30.     CloseWindow(Wrpn);
  31.   }
  32.   deallMem();
  33.   exit(code);
  34. }
  35.  
  36. static void cleanMess(
  37.   struct Window *pW
  38. )
  39. {/*------------------------------------------*
  40.   | Local function. Replies to all Intuition |
  41.   | messages pending for the given window.   |
  42.   *------------------------------------------*/
  43.  
  44.   struct IntuiMessage *pIM;
  45.  
  46.   while ( (pIM = (struct IntuiMessage *) GetMsg(pW->UserPort)) != NULL) {
  47.     ReplyMsg(pIM);
  48.   }
  49. }
  50.